home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-04-16 | 4.7 KB | 151 lines | [TEXT/CWIE] |
- // IAAccessor.h
- // Copyright: © 1994 - 1996 - 1997 - 1998 by Apple Computer, Inc., all rights reserved.
-
- #pragma once
-
- #ifndef IAAccessor_h
- #define IAAccessor_h
-
- #pragma import on
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=power
- #endif
-
- #include "IAIndex.h"
-
- //#pragma IA_BEGIN_IMPORTS
- #include <time.h>
- //#pragma IA_END_IMPORTS
-
- #pragma IA_BEGIN_EXPORTS
-
- //// IAHit: base class for search results
- class IAHit : public IAObject {
- public:
- IAHit(IAIndex* i, IADoc* d);
- virtual ~IAHit(); // deletes doc
-
- void SetIndex (IAIndex* idx) {index = idx;}
- void SetDocument (IADoc* docu) {doc = docu;}
-
- IAIndex* GetIndex() const {return index;}
- IADoc* GetDocument() const {return doc;}
-
- private:
- IAHit(IAHit&); // don't define a copy constructor
- IAIndex* index;
- IADoc* doc;
- };
-
- //// IAProgressReport: base class for progress reports
- class IAProgressReport : public IAObject {
- public:
- IAProgressReport();
- IA_INLINE ~IAProgressReport() IA_INLINE_DEF() // no-op dtor def
- void SetPercent (float value) {percent = value;}
- void SetIndex (IAIndex* idx) {index = idx;}
- void SetDocument (IADoc* docu) {doc = docu;}
-
- float GetPercent () const {return percent;}
- IAIndex* GetIndex() const {return index;}
- IADoc* GetDocument() const {return doc;}
-
- private:
- void* operator new(size_t size); // stack allocate only
- // A number between 0.0 and 100.0, inclusive.
- float percent;
- // When index is non-NULL, it names index currently being processed.
- IAIndex* index;
- // When doc is non-NULL, it names the document being processed.
- IADoc* doc;
-
- };
-
-
- class IAAccessor : public IAObject {
- public:
- // Note: the destructor does *not* delete indices.
- IAAccessor(IAIndex** indices, uint32 indexCount, uint32 type);
- virtual ~IAAccessor();
-
- // If the initialization was previously stored then it is restored,
- // otherwise it is computed from scratch, which may be slow for large indices.
- // By default uses a named block in the TOC of indices[0].storage.
- void Initialize(IAStorage* storage = NULL, IABlockID block = 0);
-
- // Computes and stores initializations so that, if the index has not changed,
- // the accessor may be initialized much faster the next time.
- // Accessor should not be initialized when this is called.
- void StoreInitialization(IAStorage* storage = NULL, IABlockID block = 0);
-
- // True iff valid initializations are available for this accessor.
- // When this is true, Initialize() will be fast, otherwise, if the storage is writable,
- // StoreInitialization() might be called instead.
- bool IsInitializationValid(IAStorage* storage = NULL, IABlockID block = 0);
-
- void SetIndices (IAIndex** indexes) {indices = indexes;}
- void SetIndexCount (uint32 count) {indexCount = count;}
- void SetAccessorType (uint32 type) {accessorType = type;}
-
- IAIndex** GetIndices () const {return indices;}
- uint32 GetIndexCount () const {return indexCount;}
- uint32 GetAccessorType () const {return accessorType;}
-
- // If the initialization was previously stored and the index is not modified then
- // it is restored, otherwise the initializations are updated regarding index
- // changes. By default uses a named block in the TOC of indices[0].storage.
- void Update(IAStorage* storage = NULL, IABlockID block = 0);
- // Stores initializations so that, if the index has not changed,
- // the accessor may be initialized much faster the next time.
- // Accessor must have been initialized when this is called.
- // This should not be called after a StoreInitialization call.
- void Store(IAStorage* storage = NULL, IABlockID block = 0);
-
- protected:
- bool isConstructed;
- bool isInitialized;
-
- // Called to actually compute initializations.
- virtual void Initializing() = 0;
-
- // Called to save and restore initializations.
- virtual IABlockSize InitsSize() = 0;
- virtual void StoringInits(IAOutputBlock* output) = 0;
- virtual void RestoringInits(IAInputBlock* input) = 0;
-
- // Called to update initializations.
- virtual void UpdatingInits(IAInputBlock* input) = 0;
- virtual void ExtendingInits() = 0;
-
- // default constructor etc. so that this can be a virtual base class
- IAAccessor();
- void Constructing(IAIndex** indices, uint32 indexCount, uint32 type);
-
- private:
- IABlockSize InitValidationSize();
- void StoreInitValidation(IAOutputBlock* output);
- bool RestoreInitValidation(IAInputBlock* input);
- bool UpdateInitValidation(IAInputBlock* input);
-
- IAIndex** indices;
- uint32 indexCount;
-
- uint32 accessorType;
- };
-
- IAExceptionCode IAAccessorAlreadyInitialized = 'VAAI';
- IAExceptionCode IAAccessorNotInitialized = 'VANI';
- IAExceptionCode IAAccessorInitInvalid = 'VAIV';
- IAExceptionCode IAAccessorUpdateInvalid = 'VAUI';
-
-
- #pragma IA_END_EXPORTS
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
- #endif
-
- #pragma import reset
-
- #endif